# -*- coding: utf-8 -*-

__author__ = 'bilibili'

# FUNCTION: filter_dict(list, dict, list, dict)
#   to filter the dict_2, save into the res_dict
# ARGS:
#   @key_list_1: the keys list for dict_1
#   @res_dict: dict_1
#   @key_list_2: the keys list for dict_2
#   @dict_2: dict_2
# RETURN:
#   dict: the updated dict_1
def filter_dict(key_list_1, res_dict, key_list_2, dict_2):
    for i in range(0, len(key_list_1)):
        res_dict[key_list_1[i]] = dict_2[key_list_2[i]]
    return res_dict

# FUNCTION: filter_dict_level_2(list, dict, list, dict)
#   to filter the dict_2's 2nd level, save into the res_dict
# ARGS:
#   @key_list_1: the keys list for dict_1
#   @res_dict: dict_1
#   @level_1_attr: level 1 attribute for dict_2
#   @key_list_2: the keys list for dict_2
#   @dict_2: dict_2
# RETURN:
#   dict: the updated dict_1
def filter_dict_level_2(key_list_1, res_dict, level_1_attr, key_list_2, dict_2):
    for i in range(0, len(key_list_1)):
        res_dict[key_list_1[i]] = dict_2[level_1_attr][key_list_2[i]]
    return res_dict